home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
os2
/
e33el2.zip
/
emacs
/
19.33
/
lisp
/
tpu-mapper.el
< prev
next >
Wrap
Lisp/Scheme
|
1996-02-17
|
15KB
|
396 lines
;;; tpu-mapper.el --- Create a TPU-edt X-windows keymap file
;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
;; Author: Rob Riepel <riepel@networking.stanford.edu>
;; Maintainer: Rob Riepel <riepel@networking.stanford.edu>
;; Keywords: emulations
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; This emacs lisp program can be used to create an emacs lisp file that
;; defines the TPU-edt keypad for emacs running on x-windows. Please read
;; the "Usage" AND "Known Problems" sections before attempting to run this
;; program.
;;; Usage:
;; Simply load this file into the X-windows version of emacs using the
;; following command.
;; emacs -q -l tpu-mapper
;; The "-q" option prevents loading of your .emacs file (commands therein
;; might confuse this program).
;; An instruction screen showing the TPU-edt keypad will be displayed, and
;; you will be prompted to press the TPU-edt editing keys. Tpu-mapper uses
;; the keys you press to create an Emacs Lisp file that will define a
;; TPU-edt keypad for your X server. You can even re-arrange the standard
;; EDT keypad to suit your tastes (or to cope with those silly Sun and PC
;; keypads).
;; Finally, you will be prompted for the name of the file to store the key
;; definitions. If you chose the default, TPU-edt will find it and load it
;; automatically. If you specify a different file name, you will need to
;; set the variable "tpu-xkeys-file" before starting TPU-edt. Here's how
;; you might go about doing that in your .emacs file.
;; (setq tpu-xkeys-file (expand-file-name "~/.my-emacs-x-keys"))
;; (tpu-edt)
;;; Known Problems:
;; Sometimes, tpu-mapper will ignore a key you press, and just continue to
;; prompt for the same key. This can happen when your window manager sucks
;; up the key and doesn't pass it on to Emacs, or it could be an Emacs bug.
;; Either way, there's nothing that tpu-mapper can do about it. You must
;; press RETURN, to skip the current key and continue. Later, you and/or
;; your local X guru can try to figure out why the key is being ignored.
;;; Code:
;;;
;;; Make sure we're running X-windows and Emacs version 19
;;;
(cond
((not (and window-system (not (string-lessp emacs-version "19"))))
(error "tpu-mapper requires running in Emacs 19, with an X display")))
;;;
;;; Decide whether we're running Lucid Emacs or Emacs itself.
;;;
(defconst tpu-lucid-emacs19-p (string-match "Lucid" emacs-version)
"Non-NIL if we are running Lucid Emacs version 19.")
;;;
;;; Key variables
;;;
(defvar tpu-kp4 nil)
(defvar tpu-kp5 nil)
(defvar tpu-key nil)
(defvar tpu-enter nil)
(defvar tpu-return nil)
(defvar tpu-key-seq nil)
(defvar tpu-enter-seq nil)
(defvar tpu-return-seq nil)
;;;
;;; Make sure the window is big enough to display the instructions
;;;
(if tpu-lucid-emacs19-p (set-screen-size (selected-screen) 80 36)
(set-frame-size (selected-frame) 80 36))
;;;
;;; Create buffers - Directions, Keys, Gold-Keys
;;;
(if (not (get-buffer "Directions")) (generate-new-buffer "Directions"))
(if (not (get-buffer "Keys")) (generate-new-buffer "Keys"))
(if (not (get-buffer "Gold-Keys")) (generate-new-buffer "Gold-Keys"))
;;;
;;; Put headers in the Keys buffer
;;;
(set-buffer "Keys")
(insert "\
;; Key definitions for TPU-edt
;;
")
;;;
;;; Display directions
;;;
(switch-to-buffer "Directions")
(insert "
This program prompts you to press keys to create a custom keymap file
for use with the x-windows version of Emacs and TPU-edt.
Start by pressing the RETURN key, and continue by pressing the keys
specified in the mini-buffer. You can re-arrange the TPU-edt keypad
by pressing any key you want at any prompt. If you want to entirely
omit a key, just press RETURN at the prompt.
Here's a picture of the standard TPU/edt keypad for reference:
_______________________ _______________________________
| HELP | Do | | | | | |
|KeyDefs| | | | | | |
|_______|_______________| |_______|_______|_______|_______|
_______________________ _______________________________
| Find |Insert |Remove | | Gold | HELP |FndNxt | Del L |
| | |Sto Tex| | key |E-Help | Find |Undel L|
|_______|_______|_______| |_______|_______|_______|_______|
|Select |Pre Scr|Nex Scr| | Page | Sect |Append | Del W |
| Reset |Pre Win|Nex Win| | Do | Fill |Replace|Undel W|
|_______|_______|_______| |_______|_______|_______|_______|
|Move up| |Forward|Reverse|Remove | Del C |
| Top | |Bottom | Top |Insert |Undel C|
_______|_______|_______ |_______|_______|_______|_______|
|Mov Lef|Mov Dow|Mov Rig| | Word | EOL | Char | |
|StaOfLi|Bottom |EndOfLi| |ChngCas|Del EOL|SpecIns| Enter |
|_______|_______|_______| |_______|_______|_______| |
| Line |Select | Subs |
| Open Line | Reset | |
|_______________|_______|_______|
")
(delete-other-windows)
(goto-char (point-min))
;;;
;;; Save <CR> for future reference
;;;
(cond
(tpu-lucid-emacs19-p
(setq tpu-return-seq (read-key-sequence "Hit carriage-return <CR> to continue "))
(setq tpu-return (concat "[" (format "%s" (event-key (aref tpu-return-seq 0))) "]")))
(t
(message "Hit carriage-return <CR> to continue ")
(setq tpu-return-seq (read-event))
(setq tpu-return (concat "[" (format "%s" tpu-return-seq) "]"))))
;;;
;;; Key mapping functions
;;;
(defun tpu-lucid-map-key (ident descrip func gold-func)
(interactive)
(setq tpu-key-seq (read-key-sequence (format "Press %s%s: " ident descrip)))
(setq tpu-key (concat "[" (format "%s" (event-key (aref tpu-key-seq 0))) "]"))
(cond ((not (equal tpu-key tpu-return))
(set-buffer "Keys")
(insert (format"(global-set-key %s %s)\n" tpu-key func))
(set-buffer "Gold-Keys")
(insert (format "(define-key GOLD-map %s %s)\n" tpu-key gold-func))
(set-buffer "Directions"))
;; bogosity to get next prompt to come up, if the user hits <CR>!
;; check periodically to see if this is still needed...
(t
(format "%s" tpu-key)))
tpu-key)
(defun tpu-emacs-map-key (ident descrip func gold-func)
(interactive)
(message "Press %s%s: " ident descrip)
(setq tpu-key-seq (read-event))
(setq tpu-key (concat "[" (format "%s" tpu-key-seq) "]"))
(cond ((not (equal tpu-key tpu-return))
(set-buffer "Keys")
(insert (format"(global-set-key %s %s)\n" tpu-key func))
(set-buffer "Gold-Keys")
(insert (format "(define-key GOLD-map %s %s)\n" tpu-key gold-func))
(set-buffer "Directions"))
;; bogosity to get next prompt to come up, if the user hits <CR>!
;; check periodically to see if this is still needed...
(t
(format "%s" tpu-key)))
tpu-key)
(fset 'tpu-map-key (if tpu-lucid-emacs19-p 'tpu-lucid-map-key 'tpu-emacs-map-key))
(set-buffer "Keys")
(insert "
;; Arrows
;;
")
(set-buffer "Gold-Keys")
(insert "
;; GOLD Arrows
;;
")
(set-buffer "Directions")
(t